﻿using CSRedis;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QskjLibrary
{
    public static class RedisHelp
    {
        private static CSRedisClient redis = null;
        private static readonly object redisLock = new object();
        private static string ipinfo= "192.168.3.65:6379,password=qskjredis!2024";
        public static CSRedisClient GetInstance()
        {
            lock (redisLock)
            {
                if (redis == null)
                { 
                    redis = new CSRedis.CSRedisClient($@"{ipinfo},defaultDatabase=0,poolsize=100,ssl=false,writeBuffer=10240");//Redis内网
                }
                return redis;
            }
        }
        private static CSRedisClient redis1 = null;
        private static readonly object redisLock1 = new object();
        public static CSRedisClient GetInstance1()
        {
            lock (redisLock1)
            {
                if (redis1 == null)
                {
                    redis1 = new CSRedis.CSRedisClient($@"{ipinfo},defaultDatabase=1,poolsize=100,ssl=false,writeBuffer=10240");//Redis内网
                }
                return redis1;
            }
        }
        private static CSRedisClient redis2 = null;
        private static readonly object redisLock2 = new object();
        public static CSRedisClient GetInstance2()
        {
            lock (redisLock2)
            {
                if (redis2 == null)
                {
                    redis2 = new CSRedis.CSRedisClient($@"{ipinfo},defaultDatabase=2,poolsize=100,ssl=false,writeBuffer=10240");//Redis内网
                }
                return redis2;
            }
        }
        private static CSRedisClient redis3 = null;
        private static readonly object redisLock3 = new object();
        public static CSRedisClient GetInstance3()
        {
            lock (redisLock3)
            {
                if (redis3 == null)
                {
                    redis3 = new CSRedis.CSRedisClient($@"{ipinfo},defaultDatabase=3,poolsize=100,ssl=false,writeBuffer=10240");//Redis内网
                }
                return redis3;
            }
        }
        private static CSRedisClient redis4 = null;
        private static readonly object redisLock4 = new object();
        public static CSRedisClient GetInstance4()
        {
            lock (redisLock4)
            {
                if (redis4 == null)
                {
                    redis4 = new CSRedis.CSRedisClient($@"{ipinfo},defaultDatabase=4,poolsize=100,ssl=false,writeBuffer=10240");//Redis内网
                }
                return redis4;
            }
        }
        private static CSRedisClient redis5 = null;
        private static readonly object redisLock5 = new object();
        public static CSRedisClient GetInstance5()
        {
            lock (redisLock5)
            {
                if (redis5 == null)
                {
                    redis5 = new CSRedis.CSRedisClient($@"{ipinfo},defaultDatabase=5,poolsize=100,ssl=false,writeBuffer=10240");//Redis内网
                }
                return redis5;
            }
        }
        private static CSRedisClient redis6 = null;
        private static readonly object redisLock6 = new object();
        public static CSRedisClient GetInstance6()
        {
            lock (redisLock6)
            {
                if (redis6 == null)
                {
                    redis6 = new CSRedis.CSRedisClient($@"{ipinfo},defaultDatabase=6,poolsize=100,ssl=false,writeBuffer=10240");//Redis内网
                }
                return redis6;
            }
        }
        private static CSRedisClient redisSaas2 = null;
        private static readonly object redisLockSaas2 = new object();
        public static CSRedisClient GetInstanceSaas2()
        {
            lock (redisLockSaas2)
            {
                if (redisSaas2 == null)
                {
                    redisSaas2 = new CSRedis.CSRedisClient("192.168.2.228:16379,defaultDatabase=2,poolsize=100,ssl=false,writeBuffer=10240");//Redis内网
                }
                return redisSaas2;
            }
        }
    }
}
